<?php 
	session_start();
	include_once("header.php");
	include_once("top_menu.php");
	$connection = mysql_pconnect("localhost" , "root" , "31122001");
    mysql_select_db("kt_site");
    $id = $_SESSION['id'];
    $result = mysql_query("SELECT * FROM users WHERE id = '".$id."';");
    $num_rows = mysql_num_rows($result);
    $user = mysql_fetch_array($result);
    $lastname = $user['lastname'];
    $firstname = $user['firstname'];
    $phonenumber= $user['phonenumber'];
    $email = $user['email'];
    $password = "";
    $password_confirmation = "";
    if (isset($_SESSION['error'])) {
		echo $_SESSION['error']."<br>";
		$lastname = $_SESSION['lastname'];
		$firstname = $_SESSION['firstname'];
		$phonenumber = $_SESSION['phonenumber'];
		$email = $_SESSION['email'];
		$password = $_SESSION['password'];
		$password_confirmation = $_SESSION['password_confirmation'];
	}
	unset($_SESSION['error']);
?>
<title>
	Editing User Info
</title>
<div class = 'header-update'>
	Editing User Info
</div>
<form action = "edit_info_process.php" method = "POST">
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			Last Name:
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'text' class = 'bordered_input' size = '30' name = 'lastname' value = '".$lastname."'>";
			?>
		</div>
	</div>
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			First Name:
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'text' class = 'bordered_input' size = '30' name = 'firstname' value = '".$firstname."'>";
			?>
		</div>
	</div>
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			Phone Number:
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'text' class = 'bordered_input' size = '30' name = 'phonenumber' value = '".$phonenumber."'>";
			?>
		</div>
	</div>
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			E-Mail:
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'text' class = 'bordered_input' size = '30' name = 'email' value = '".$email."'>";
			?>
		</div>
	</div>
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			Password
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'password' class = 'bordered_input' size = '30' name = 'password' value = '".$password."'>";
			?>
		</div>
	</div>
	<div class = 'row-update'>
		<div id = 'row-update-c1'>
			Password confirmation:
		</div>
		<div id = 'row-update-c2'>
			<?php 
				echo "<input type = 'password' class = 'bordered_input' size = '30' name = 'password_confirmation' value = '".$password_confirmation."'>";
			?>
		</div>
	</div>
	<input type="submit" value="Update" name="EditInfo" class = 'button button-update'>
</form>